/* common.h */
#ifndef COMMON_H
#define COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <pthread.h>
#include <stdatomic.h>
#include <errno.h>
#include <string.h>

#define SHM_KEY            (0x123)
#define SEM_KEY            (0x567)
#define HOST_CMD_MIN       (100)
#define SMART_HOST_CMD_MIN (200)
#define THREAD_NAME_MAX    (16)
#define TRUE               (1)
#define FALSE              (0)

typedef enum {
    HOST_CMD_TEST1 = HOST_CMD_MIN,
    HOST_CMD_TEST2,
    HOST_CMD_TEST3,
    HOST_CMD_MAX,
    
    SMART_HOST_CMD_TEST1 = SMART_HOST_CMD_MIN,
    SMART_HOST_CMD_TEST2,
    SMART_HOST_CMD_TEST3,
    SMART_HOST_CMD_MAX,
    HOST_CMD_EXIT = 500
} HOST_CMD;

typedef struct {
    HOST_CMD cmd_id;
    int param;
    int value;
} shm_buf_data_t;

#define DEBUG(fmt, ...) \
    printf("[DEBUG][%s:%d] " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#define ERROR(fmt, ...) \
    fprintf(stderr, "[ERROR][%s:%d] " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)

#endif
